package maincode;
import org.apache.commons.math3.stat.correlation.PearsonsCorrelation;


public class corGenator {
	
	double arr1[];
	double arr2[];
	
	public corGenator(double arr1[],double arr2[]){
		this.arr1 = arr1;
		this.arr2 = arr2;
	}
	
	
	public void arrShift(int timeShift){
		double newArr_1[] = new double[arr1.length - timeShift];
		double newArr_2[] = new double[arr2.length - timeShift];

		for(int i=0; i<newArr_1.length; i++){
			newArr_1[i] = this.arr1[i];			
			newArr_2[i] = this.arr2[i+timeShift];
		}
		
		this.arr1 = newArr_1;
		this.arr2 = newArr_2;
	}
	
	public double returnCor(int timeShift){
		arrShift(timeShift);
		PearsonsCorrelation tempInstance = new PearsonsCorrelation();
		return tempInstance.correlation(arr1, arr2);
	}
	
}
